import { isNullPm } from './baseMethods';
import { precisionFilter } from './bignumbers';
interface BASECONFIG {
  x?: number;
  y?: number;
}

/**
 * @exports relativeAddition 加法计算
 * @param param param.x + param.y  { x:0,y:0 }
 */
export const relativeAddition = (param: BASECONFIG) => {
  param.x = isNullPm(param.x) ? 0 : param.x;
  param.y = isNullPm(param.y) ? 0 : param.y;
  return precisionFilter('x + y', param);
};

/**
 * @exports multiplication 乘法计算
 * @param param param.x * param.y  { x:0,y:0 }
 */
export const multiplication = (param: BASECONFIG) => {
  return !isNullPm(param.x) && !isNullPm(param.y) ? precisionFilter('x * y', param) : 0;
};

/**
 * @exports subtraction 减法计算
 * @param param param.x * param.y  { x:0,y:0 }
 */
export const subtraction = (param: BASECONFIG) => {
  return !isNullPm(param.x) && !isNullPm(param.y) ? precisionFilter('x - y', param) : 0;
};

/**
 * @exports divisionMethod 除法计算
 * @param param
 * @returns
 */
export const divisionMethod = (param) => {
  return !isNullPm(param.x) && !isNullPm(param.y) ? precisionFilter('x / y', param) : 0;
};
